package com.bblocks.enums;

import com.bblocks.config.SwaggerDisplayEnum;
import com.bblocks.exception.ServiceException;
import lombok.Getter;
import lombok.NonNull;

/**
 * 环境枚举
 */
@Getter
@SwaggerDisplayEnum(index = "code", name = "name")
public enum EnvEnum {
	Dev("dev", "开发环境"),
	Test("test", "测试环境"),
	Prd("prd", "生产"),

	;
	private String code;
	private String name;



	EnvEnum( String code,String name) {
		this.code = code;
		this.name = name;
	}


	@Override
	public String toString() {
		return String.valueOf(code) + ":" + name;
	}

	private static EnvEnum[] all =  EnvEnum.values();
	public static EnvEnum getEnvEnum( String code) {
		if(code == null)
			return null;
		for (EnvEnum c : all) {
			if (c.getCode().equalsIgnoreCase(code) ) {
				return c;
			}
		}
		throw new ServiceException("无此类型："+code);
	}
}
